package com.ahut.gsmcommon.controller;

import com.ahut.gsmcommon.entity.User;
import com.ahut.gsmcommon.service.UserService;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Author gan.sumin@mail.com
 * @data 2018/6/1916:24
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping
    @RequestMapping("/{id}")
    public User getUserById(@PathVariable(value = "id",required = false,name = "id") Integer id){
        User userInfo = userService.getUserInfo(id);
        return userInfo;
    }
    @PostMapping
    @RequestMapping("/save")
    public void saveUser(User user){
        user.setId(2);
        user.setUserName("1234");
        user.setPassWord("123456");
        user.setCreateTime(new Date());
        userService.saveUser(user);
    }
}
